﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LeanEngine.Data.Linq.Language
{
    public sealed class ColumnToken : IQueryToken
    {
        #region Constructor Members

        public ColumnToken(TableToken table)
        {
            this.Table = table;
        }

        #endregion

        #region PropertyInfo Members

        public TableToken Table { get; private set; }
        public string Name { get; set; }
        public string PropertyName { get; set; }

        #endregion

        #region ILanguageToken Members

        public string GetStatement()
        {
            return string.IsNullOrEmpty(this.Table.Alias) ? this.Name : this.Table.Alias + "." + this.Name;
        }

        #endregion
    }
}
